Imports System
Imports System.Collections.Generic
Imports System.Text


Public Enum ReturnType
    Any
    [Date]
    Number
    [String]
    [Boolean]
    none
End Enum


Public Class Parser

    Private _KnownDesignators As SortedList(Of String, Object)
    Private _KnownFunctions As ParserFuncDefList
    Private _Tokens As Tokenizer

    Private _ResultNodes As Tree_Node_List

    Public Sub New(ByVal StringExpression As String)
        Me.New(StringExpression, New SortedList(Of String, Object)(), New ParserFuncDefList())

    End Sub
    Public Sub New(ByVal StringExpression As String, ByVal Designators As SortedList(Of String, Object))
        Me.New(StringExpression, Designators, New ParserFuncDefList())

    End Sub

    Public Sub New(ByVal StringExpression As String, ByVal Functions As ParserFuncDefList)
        Me.New(StringExpression, New SortedList(Of String, Object)(), Functions)

    End Sub

    Public Sub New(ByVal StringExpression As String, ByVal Designators As SortedList(Of String, Object), ByVal Functions As ParserFuncDefList)
        _KnownDesignators = Designators
        _KnownFunctions = Functions
        _Tokens = New Tokenizer(StringExpression)

        _ResultNodes = Tree_Node.BuildTree(Me, _Tokens)
    End Sub

    Public ReadOnly Property ParseTree() As Tree_Node_List
        Get
            Return _ResultNodes
        End Get
    End Property

    Public ReadOnly Property Tokens() As Tokenizer
        Get
            Return _Tokens
        End Get
    End Property

    Public Property Designators() As SortedList(Of String, Object)
        Get
            Return _KnownDesignators
        End Get
        Set(ByVal value As SortedList(Of String, Object))
            _KnownDesignators = value
        End Set
    End Property

    Public Property Functions() As ParserFuncDefList
        Get
            Return _KnownFunctions
        End Get
        Set(ByVal value As ParserFuncDefList)
            _KnownFunctions = value
        End Set
    End Property
End Class


